<template>
	<view class="content" style="padding-bottom: 70px;">
		<view class="back-top">
			<image src="/static/TOP_background@2x.png" mode="widthFix"></image>
		</view>
		<view class="top-search">
			<view class="search-left" style="display: flex;">
				<view>
					<navigator url="/pages/login/index">
						<image src="/static/login-icon.png" mode=""></image>
						<text style="margin-right: 10px;">登录</text>
					</navigator>
				</view>
				<view>
					<navigator url="/pages/register/index">
						<image src="/static/reg-icon.png" mode=""></image>
						<text>注册</text>
					</navigator>
				</view>
			</view>
		</view>
		<swiper class="swiper" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000">
			<swiper-item v-for="(i,index) in 3" :key="index">
				<image src="../../static/part-00354-1289.jpg" mode=""></image>
			</swiper-item>
		</swiper>
		<view class="">
			<view class="ad">
				<div style="width: 100%; height:20px;border: 2px soild #ccc;">
					请输入关键字...
				</div>
				<div style="display: flex;align-items: center;">
					<image src="../../static/souch-icon.png" mode=""></image>
				</div>
			</view>
		</view>
		<uni-section title="自定义列数" type="line" padding>
			<uni-grid :column="3" :highlight="true">
				<uni-grid-item v-for="(item, index) in list" :key="index">
					<view class="grid-item-box" style="background-color: #fff;">
						<image :src="item.img" mode="" style="width: 30px;height: 30px;"></image>
						<text class="text">{{item.name}}</text>
					</view>
				</uni-grid-item>
			</uni-grid>
		</uni-section>
		<view class="new">
			<view class="new_">
				<view class="new-head">
					<!-- 新人专享 -->
				</view>
				<view class="slide-img">
					<navigator url="/pages/detail/detail" v-for="(i,index) in 6" :key="index"
						style="display: flex;flex-direction: column;justify-content: center;align-items: flex-start;width: 47%;margin: 5px 5px 0 0;">
						<image src="../../static/part-00354-1289.jpg" mode=""></image>
						<view class="cart1">
							<view class="goods-name">
								菲律宾火龙果
							</view>
							<view style="display: flex;">
								<view>
									价格
								</view>
								<view style="color: #ff5041;">￥17.9</view>
							</view>
						</view>
					</navigator>
				</view>
			</view>
		</view>
		<view style="display: flex; position: fixed;bottom: 50px;width: 100%;z-index: 999;background-color: #FF6139;">
			<view
				style="background-color: #FF6139; flex: 1;display: flex;flex-direction: column;align-items: center;color: #ffff;"
				v-for="(item,index) in footlist" :key="index">
				<image :src="item.img" mode="" style="width: 30px;height: 30px;padding-top: 5px;"></image>
				<text class="text">{{item.name}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../request.js'
	import Nav from '../../components/navbar.vue'
	export default {
		data() {
			return {
				title: ['全部', '热销爆款', '新品尝鲜', '瓜果菩提', '柑橘橙柚'],
				indexData: {},
				goodsList: [],
				id: 0,
				word: true,
				num: 1,
				list: [
					{
						id:1,
						img: '../../static/shipin.png',
						name: '休闲食品',
					},
					{
						id:2,
						img: '../../static/lingshi.png',
						name: '进口零食',
					},
					{
						id:3,
						img: '../../static/yinliao.png',
						name: '汽水饮料',
					},
					{
						id:4,
						img: '../../static/jiushui.png',
						name: '国际酒水',
					},
					{
						id:5,
						img: '../../static/kafei.png',
						name: '咖啡饮品',
					},
					{
						id:6,
						img: '../../static/jiat.png',
						name: '休闲零食',
					},
				],
				footlist: [
					{
						id:1,
						img: '../../static/DH.png',
						name: '电话咨询',
					},
					{
						id:2,
						img: '../../static/QQ.png',
						name: 'QQ客服',
					},
					{
						id:3,
						img: '../../static/ZX.png',
						name: '在线留言',
					},
					{
						id:4,
						img: '../../static/DT.png',
						name: '在线地图',
					},
					{
						id:5,
						img: '../../static/xx.png',
						name: '信息咨询',
					},
				]
			}
		},
		onLoad() {
			this.getindex()
			this.getGoodsList()
		},
		components: {
			Nav
		},
		computed: {
			// category() {
			// 	var cate = this.indexData.category_list.map(i => {
			// 		return i.name
			// 	})
			// 	return cate
			// }
		},
		methods: {
			// 加入购物车
			addcart() {
				uni.showToast({
					title: '已加入购物车',
					icon: 'success'
				})
				this.word = false
			},
			// 加
			add() {
				this.num++
				uni.showToast({
					title: '已加入购物车',
					icon: 'success'
				})
			},
			// 减
			reduce() {
				if (this.num > 0)
					this.num--
				if (this.num == 0)
					this.word = true
			},
			// 切换分类
			kind(id) {
				this.goodsList = []
				this.id = id
				this.getGoodsList()
			},
			// 商品列表接口
			getGoodsList() {
				request({
					data: {
						controller: 'index.load_gps_goodslist',
						pageNum: '1',
						per_page: '12',
						gid: this.id
					},
					success: (res) => {
						this.goodsList = res.data.list
					}
				})
			},
			// 首页轮播图信息
			getindex() {
				request({
					data: {
						controller: 'index.index_info'
					},
					success: (res) => {
						this.indexData = res.data
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {

		// padding-bottom: var(--window-bottom);
		.goods-name {
			font-size: 14px;
			font-weight: 600;
			color: #333;
		}

		.goods-part {
			background-color: #f5f5f5;
			padding: 20rpx;

			.goods {
				background-color: #fff;
				border-radius: 20rpx;
				overflow: hidden;
				margin-bottom: 20rpx;

				.goods-desc {
					padding: 20rpx;

					.goods-desc1 {
						font-size: 15px;
						font-weight: bold;
					}

					.goods-desc2 {
						font-size: 13px;
						color: #999;
						margin: 10rpx 0;
					}

					.goods-desc3 {
						line-height: 30px;
						display: flex;
						justify-content: space-between;
						align-items: center;

						.oneprice {
							font-size: 22px;
							font-weight: bold;
							color: #ff5344;
						}

						.buy {
							background-color: #ff5344;
							padding: 0rpx 30rpx;
							border-radius: 40rpx;
							color: #fff;
						}

					}

					.goods-desc4 {
						font-size: 12px;
						color: #999;
					}
				}

				.logo {
					width: 100%;
					height: 400rpx;
				}
			}
		}

		.new {
			background-color: #f6f6f6;
			padding-top: 20rpx;

			.new_ {
				background-color: #fff;
				padding: 20rpx 0;

				.new-head {
					border-left: 8rpx solid #ff5344;
					padding-left: 5px;
					font-weight: bold;
				}

				.slide-img {
					display: flex;
					flex-wrap: wrap;
					justify-content: space-between;
					padding: 20rpx;

					.cart1 {
						display: flex;
						flex-direction: column;
						align-items: center;
						justify-content: space-between;


						image {
							width: 24px;
							height: 24px;
							vertical-align: top;
						}
					}

					image {
						width: 95%;
						height: 300rpx;
					}
				}
			}

		}

		.ad {
			margin: 10rpx;
			height: 50rpx;
			border-radius: 40rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 20rpx;
			border: 1px solid #333;

			image {
				width: 24px;
				height: 24px;
			}

			swiper {
				height: 80rpx;
				width: 90%;
				color: #fff;

				.swiper-item {
					line-height: 80rpx;
					font-size: 12px;
				}
			}
		}

		.heade-img {
			text-align: center;
			margin-top: 20rpx;

			image {
				width: 710rpx;
				height: 200rpx;
			}
		}

		.swiper {
			width: 100%;
			height: 320rpx;
			text-align: center;

			image {
				width: 710rpx;
				height: 320rpx;
				border-radius: 12rpx;
			}
		}

		.back-top {
			position: absolute;
			z-index: -1;

			image {
				width: 750rpx;
			}
		}

		.top-search {
			padding: 20rpx;
			// color: #fff;
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #FAA79B;

			.search-left {
				font-size: 14px;
				color: #fff;

				image {
					width: 21px;
					height: 21px;
					vertical-align: top;
				}
			}

			.search-right {
				background: #fff url('../../static/search.png') no-repeat 25rpx 10rpx;
				background-size: 20px 20px;
				width: 180rpx;
				height: 60rpx;
				border-radius: 30rpx;

				input {
					text-align: right;
					margin-right: 25rpx;
					margin-top: 8rpx;
				}
			}
		}

		.add {
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 160rpx;

			image {
				width: 24px;
				height: 24px;
			}
		}
	}

	.image {
		width: 25px;
		height: 25px;
	}

	.text {
		font-size: 14px;
		margin-top: 5px;
	}

	.example-body {
		/* #ifndef APP-NVUE */
		// display: block;
		/* #endif */
	}

	.grid-dynamic-box {
		margin-bottom: 15px;
	}

	.grid-item-box {
		flex: 1;
		// position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.grid-item-box-row {
		flex: 1;
		// position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.grid-dot {
		position: absolute;
		top: 5px;
		right: 15px;
	}

	.swiper {
		height: 420px;
	}

	/* #ifdef H5 */
	@media screen and (min-width: 768px) and (max-width: 1425px) {
		.swiper {
			height: 630px;
		}
	}

	@media screen and (min-width: 1425px) {
		.swiper {
			height: 830px;
		}
	}
</style>